<template>
  <div>
      <myheader/>
      选择分类<br/>
      <reply :data='catelist'/>

      <van-field
      v-model="form.name"
      name="name"
      label="名称"
      placeholder="名称"
      :rules="[{required: true, message: '请填写名称'}]"
      />
      <van-field
      v-model="form.level"
      name="level"
      label="等级"
      placeholder="等级"
      :rules="[{required: true, message: '请填写等级'}]"
      />
      <van-field
      v-model="form.params"
      name="params"
      label="参数配置"
      placeholder="参数配置"
      />
      <van-button round block type="info" style="width:100px"  @click="add">提交</van-button>
  </div>
</template>

<script>

import myheader  from  '@/components/myheader'
import reply  from  '@/components/reply'

export default {
    data(){
        return{
            form:{parent:0},
            catelist:{}
        }
    },
    methods:{
        add(){
            // 获取父id，如果有更新
            let pid = localStorage.getItem('pid')
            if(pid){
                this.form.parent = pid
            }
            this.axios.post('course/cateM',this.form).then(res=>{})
        },
        // 获取所有分类
        getCatelist(){
            this.axios.get('course/cateM').then(res=>{
                this.catelist={'id':0,'name':'','son':res.data.list}
            })
        }
    },
    mounted(){
        this.getCatelist()
    },
     mounted() {
    this.getUserinfo()
  },
    components:{
        'myheader':myheader,
        'reply':reply
    }
}
</script>

<style>

</style>